'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
     const { INTEGER, STRING, DATE } = Sequelize;
    await queryInterface.createTable('sys_role', {
      role_id: {
        type: INTEGER(20),
        comment: "角色ID",
        allowNull: false,
        primaryKey: true,
        autoIncrement: true
      },
      role_name:{
        type:STRING(30),
        comment:"角色名称",
        allowNull:false
      },
      role_key:{
        type:STRING(100),
        comment:"角色权限字符串",
        allowNull:false
      },
      role_sort:{
        type:INTEGER(4),
        comment:"显示顺序",
        allowNull:false
      },
      data_scope:{
        type:STRING(1),
        comment:"数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限）",
        defaultValue:"1"
      },
      menu_check_strictly:{
        type:INTEGER(1),
        comment:"菜单树选择项是否关联显示",
        defaultValue:1
      },
      dept_check_strictly:{
        type:INTEGER(1),
        comment:"部门树选择项是否关联显示",
        defaultValue:1
      },
      status:{
        type:STRING(1),
        comment:"角色状态（0正常 1停用）",
        allowNull:false
      },
      create_by:{
        type:STRING(64),
        comment:"创建者",
        defaultValue:""
      },
      update_by:{
        type:STRING(64),
        comment:"更新者",
        defaultValue:""
      },
      remark:{
        type:STRING(500),
        comment:"备注",
        defaultValue:""
      },
      created_at:{
        type:DATE,
        comment:"创建时间",
      },
      updated_at:{
        type:DATE,
        comment:"更新时间",
      },
      deleted_at:{
        type:DATE,
        comment:"删除时间",
      }
    });
  },

  down: async (queryInterface, Sequelize) => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('sys_role');
  }
};
